﻿@using SCMS.Resource
@model IEnumerable<SCMS.UI.Models.ViewFSummaryDetails>
@if (Model.Count() > 0)
{
    <div id="tablewrapper">
        <div id="tableheader">
            <div class="search">
                <b>@Resources.Global_String_SearchBy:</b><br />
                <select id="columns" onchange="sorter.search('query')">
                </select>
                <input type="text" id="query" onkeyup="sorter.search('query')" />
            </div>
            <span class="details">
                <div>
                    @Resources.Global_String_Records <span id="startrecord"></span>-<span id="endrecord"></span> @Resources.Global_String_Of <span id="totalrecords">
                    </span>
                </div>
            </span>
        </div>
        <br />
        <br />
        <br />
        <table width="98%" align="center" cellpadding="0" cellspacing="0" border="0" id="table"
            class="tinytable">
            <thead>
                <tr>
                    <th width="21%">
                        <h3>
                            @Resources.Global_String_AssetNo</h3>
                    </th>
                    <th width="14%">
                        <h3>
                            @Resources.Global_String_BrandName</h3>
                    </th>
                    <th width="14%">
                        <h3>
                            @Resources.Global_String_Model</h3>
                    </th>
                    <th width="8%">
                        <h3>
                            @Resources.Global_String_ModelYear</h3>
                    </th>
                    <th width="10%">
                        <h3>
                            @Resources.FleetManager_LoadNewFleetDetail_PlateNo</h3>
                    </th>
                    <th width="10%">
                        <h3>
                            @Resources.FleetManger_LoadSummary_AverageFuelConsumed</h3>
                    </th>
                    @if (UserContext.HasPermission(StandardPermissionProvider.ApproversManage))
                    {                    
                        <th width="21%">
                            <h3>
                                @Resources.Global_String_Manage</h3>
                        </th>
                    }
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
        
@*<tr onclick="sendRequest('/FleetManager/LoadFleetDetails/@item.EntityFleetDetails.Id', 'fleetDiv', 'loading');" style=" cursor:pointer;">*@
                    <tr>
                        <td>@item.EntityFleetDetails.Asset.AssetNumber
                        </td>
                        <td>
                            @if (item.EntityFleetDetails.VehicleModel != null)
                            {     @item.EntityFleetDetails.VehicleModel.VehicleMake.Name}
                        </td>
                        <td>
                            @if (item.EntityFleetDetails.VehicleModel != null)
                            {  @item.EntityFleetDetails.VehicleModel.Name}
                        </td>
                        <td>@item.EntityFleetDetails.ModelYear
                        </td>
                        <td>@item.EntityFleetDetails.PlateNo
                        </td>
                        <td>
                            @*@if (item.EntityFleetDetails.InsuranceType != null)
                            { @item.EntityFleetDetails.InsuranceType.Name}*@
                                    @item.AvrgFuelConsumption                                     
                        </td>
                        @if (UserContext.HasPermission(StandardPermissionProvider.ApproversManage))
                        {                    
                            <td align="center">
                                @Ajax.ActionLink(Resources.Global_String_Details, "LoadFleetDetails", new { id = item.EntityFleetDetails.Id }, new AjaxOptions
                               {
                                   UpdateTargetId = "fleetDiv",
                                   LoadingElementId = "loading",
                                   OnSuccess = "initPostFundsView(1); "
                               })&nbsp;| &nbsp;
                                @Ajax.ActionLink(Resources.Global_String_Edit, "LoadNewFleetDetail", new { fleetId = item.EntityFleetDetails.Id }, new AjaxOptions
                               {
                                   OnBegin = "ShowDialogue('" + item.EntityFleetDetails.Asset.AssetNumber + "')",
                                   UpdateTargetId = "popup-page",
                                   LoadingElementId = "popup-loading",
                                   OnSuccess = "CenterPopup();"
                               }) &nbsp;| &nbsp;
                                @Ajax.ActionLink(Resources.Global_String_Delete, "DeleteFleet", new { fleetId = item.EntityFleetDetails.Id }, new AjaxOptions
                               {
                                   UpdateTargetId = "fleetDiv",
                                   LoadingElementId = "loading",
                                   Confirm = string.Format(Resources.Global_String_ConfirmDelete, item.EntityFleetDetails.Asset.AssetNumber),
                                   OnSuccess = "initPostFundsView(0);"
                               })
                            </td>
                        }
                    </tr>
        
                }
            </tbody>
        </table>
        <div id="tablefooter">
                <div id="tablenav">
                    <div>
                        <img src="../../Content/images/pager/first.gif" width="16" height="16" alt="@Resources.Global_String_FirstPage"
                            onclick="sorter.move(-1,true)" />
                        <img src="../../Content/images/pager/previous.gif" width="16" height="16" alt="@Resources.Global_String_PreviousPage"
                            onclick="sorter.move(-1)" />
                        <img src="../../Content/images/pager/next.gif" width="16" height="16" alt="@Resources.Global_String_NextPage"
                            onclick="sorter.move(1)" />
                        <img src="../../Content/images/pager/last.gif" width="16" height="16" alt="@Resources.Global_String_LastPage"
                            onclick="sorter.move(1,true)" />
                    </div>
                    <div>
                        <select id="pagedropdown">
                        </select>
                    </div>
                    <div>
                        <a href="javascript:sorter.showall()">@Resources.Global_String_ViewAll</a>
                    </div>
                </div>
                <div id="tablelocation">
                    <div>
                        <select onchange="sorter.size(this.value)">
                            <option value="5">5</option>
                            <option value="10">10</option>
                            <option value="20" selected="selected">20</option>
                            <option value="50">50</option>
                            <option value="100">100</option>
                        </select>
                        <span>@Resources.Global_String_EntriesPerPage</span>
                    </div>
                    <div class="page">
                        @Resources.Global_String_Page <span id="currentpage"></span>@Resources.Global_String_Of <span id="totalpages"></span>
                    </div>
                </div>
            </div>
    </div>
}
else
{
    <i style="text-align: center;">@Resources.FleetManager_LoadSummary_NoDetails</i>
}
